package com.rongshu.view.home.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.home.bean.LabelResponse;
import com.rongshu.view.home.contract.PerfectLableView;

import java.util.List;

import rx.Subscriber;

public class PerfectLablePresenter extends BasePresenter<PerfectLableView> {

    public PerfectLablePresenter(Context context) {
        super(context);
    }

    /**
     * 获取标签
     */
    public void getlabels(int rnd, int type, String sign) {
        RetorfitService.getlabel(rnd, type, sign)
                .subscribe(new Subscriber<LabelResponse>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(LabelResponse labelResponse) {
                        if (getView() != null) {
                            getView().onLabels(labelResponse);
                        }
                    }
                });
    }

    /**
     * 完善标签
     */
    public void postPerfectLable(int user_id, String sign, List<Integer> integers) {
        RetorfitService.postPerfectLable(user_id, sign, integers)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onPerfectLables(bean);
                        }
                    }
                });
    }
}
